<template>
  <a-row :gutter="24">
    <a-col :md="24">
      <a-card :style="cardStyle" :bordered="false">
        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
          <!-- 搜索区域 -->
          <a-form layout="inline" @keyup.enter.native="searchQuery">
            <a-row :gutter="24">
              <a-col :md="6" :sm="24">
                <a-form-item :label="$t('inPrint.process_name')" :labelCol="labelCol" :wrapperCol="wrapperCol">
                  <a-input :placeholder="$t('inPrint.PleaseNameQuery')" v-model="queryParam.flowName"></a-input>
                </a-form-item>
              </a-col>
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                <a-col :md="6" :sm="24">
                  <a-button type="primary" @click="searchQuery">{{$t('setailManagement.query')}}</a-button>
                  <a-button style="margin-left: 8px" @click="searchReset">{{$t('setailManagement.reset')}}</a-button>
                </a-col>
              </span>
            </a-row>
          </a-form>
        </div>
        <!-- 操作按钮区域 -->
        <div class="table-operator"  style="margin-top: 5px">
          <a-button v-if="btnEnableList.indexOf(1)>-1" @click="handleAdd" type="primary" icon="plus">{{$t('setailManagement.newlyAdded')}}</a-button>
          <a-dropdown>
            <a-menu slot="overlay">
              <a-menu-item key="1" v-if="btnEnableList.indexOf(1)>-1" @click="batchDel"><a-icon type="delete"/>{{$t('setailManagement.delete')}}</a-menu-item>
            </a-menu>
            <a-button>
              {{$t('setailManagement.batchOperation')}} <a-icon type="down" />
            </a-button>
          </a-dropdown>
        </div>
        <!-- table区域-begin -->
        <div>
          <a-table
            ref="table"
            size="middle"
            bordered
            rowKey="id"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :scroll="scroll"
            :loading="loading"
            :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
            @change="handleTableChange">
            <span slot="action" slot-scope="text, record">
              <a @click="handleEdit(record)">{{$t('setailManagement.edit')}}</a>
                            <a-divider v-if="btnEnableList.indexOf(1)>-1" type="vertical" />
              <a @click="handleSetFunction(record)">{{$t('systemManagement.allocationFunction')}}</a>
              <a-divider type="vertical" />
<!--              <a type="primary" @click="userSetting(record)">人员设置</a>-->
<!--               <a-divider type="vertical" />-->
              <a  @click="detailUser(record)">{{$t('inPrint.assignPermissions')}}</a>
               <a-divider v-if="btnEnableList.indexOf(1)>-1" type="vertical" />
               <a-popconfirm v-if="btnEnableList.indexOf(1)>-1" :title="$t('setailManagement.areDelete')" @confirm="() => handleDelete(record.id)">
                              <a>{{$t('setailManagement.delete')}</a>
               </a-popconfirm>
            </span>
          </a-table>
        </div>
        <!-- table区域-end -->
        <!-- 表单区域 -->
        <workflow-config-modal ref="modalForm" @ok="modalFormOk"></workflow-config-modal>
        <config-role-function-modal ref="configRoleFunctionModal" @ok="configRoleFunction"></config-role-function-modal>
        <workflow-config-set-user ref="WorkflowConfigSetUser" @ok="WorkflowConfigDetailModal"></workflow-config-set-user>
      </a-card>
    </a-col>
  </a-row>
</template>
<!-- b y 7 5 2 7  1 8 9 2 0 -->
<script>
  import WorkflowConfigModal from '../workflow/modules/WorkflowConfigModal'
  import ConfigRoleFunctionModal from './modules/ConfigRoleFunctionModal'
  import WorkflowConfigSetUser from './modules/WorkflowConfigSetUser'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import JDate from '@/components/jeecg/JDate'
  export default {
    name: "ProgressQueryList",
    mixins:[JeecgListMixin],
    components: {
      WorkflowConfigSetUser,
      WorkflowConfigModal,
      ConfigRoleFunctionModal,
      JDate
    },
    data () {
      return {
        roleFunctionModalVisible: false,
        currentRoleId: '',
        labelCol: {
          span: 5
        },
        wrapperCol: {
          span: 18,
          offset: 1
        },
        // 查询条件
        queryParam: {name:'',type:''},
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:40,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          { title: this.$t('inPrint.process_key'), align:"center", dataIndex: 'flowKey', width:200 },
          { title: this.$t('inPrint.process_name'), align:"center", dataIndex: 'flowName', width:80 },
          {
            title: this.$t('setailManagement.operation'),
            dataIndex: 'action',
            width:120,
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
        url: {
          list: "/workflowConfig/list",
          delete: "/workflowConfig/delete",
          deleteBatch: "/workflowConfig/deleteBatch",
        }
      }
    },
    computed: {

    },
    created () {
    },
    methods: {
      handleEdit: function (record) {
        this.$refs.modalForm.edit(record);
        this.$refs.modalForm.title = this.$t('setailManagement.edit');
        this.$refs.modalForm.disableSubmit = false;
        if(this.btnEnableList.indexOf(1)===-1) {
          this.$refs.modalForm.isReadOnly = true
        }
      },
      handleSetFunction(record) {
        this.$refs.configRoleFunctionModal.edit(record);
        this.$refs.configRoleFunctionModal.title = this.$t('systemManagement.allocationFunction');
        this.$refs.configRoleFunctionModal.disableSubmit = false;
      },
      detailUser(record) {
        this.$refs.WorkflowConfigSetUser.edit(record);
        this.$refs.WorkflowConfigSetUser.title = this.$t('inPrint.assignPermissions');
        this.$refs.WorkflowConfigSetUser.disableSubmit = false;
        // if(this.btnEnableList.indexOf(1)===-1) {
        //   this.$refs.modalForm.isReadOnly = true
        // }
      },
      configRoleFunction(id) {
        //重载列表
        this.loadData();
        this.roleFunctionModalVisible = true;
        this.currentRoleId = id
      },
      WorkflowConfigDetailModal(id) {
        //重载列表
        this.loadData();
        this.roleFunctionModalVisible = true;
        this.currentRoleId = id
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>